package com.bdqn.service;

import com.bdqn.mapper.SysRoleMapper;
import com.bdqn.pojo.SysRole;
import com.bdqn.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;

import java.util.ArrayList;
import java.util.List;

/**
 * SysRoleServiceImpl
 *
 * @author LILIBO
 * @since 2022-09-13
 */
public class SysRoleServiceImpl implements SysRoleService {

    /**
     * 日志
     */
    private static final Logger logger = LogManager.getLogger(SysUserServiceImpl.class);

    /**
     * 获取所有角色数据
     *
     * @return
     */
    @Override
    public List<SysRole> getAll() {
        List<SysRole> list = new ArrayList<>();
        SqlSession sqlSession = null;
        try {
            sqlSession = MyBatisUtil.createSqlSession();
            list = sqlSession.getMapper(SysRoleMapper.class).getAll();
        } catch (Exception e) {
            logger.error(e.getMessage());
        } finally {
            MyBatisUtil.closeSqlSession(sqlSession);
        }
        return list;
    }

}
